Public Class UIRegionsEditor
    Inherits System.Drawing.Design.UITypeEditor

    Public Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal value As Object) As Object
        Dim objRegions As MyRegions = CType(value, MyRegions)

        objRegions.SetUndo()
        With New frmRegions(objRegions)
            Select Case .ShowDialog()
                Case DialogResult.OK
                    objRegions.ClearUndo()

                Case DialogResult.Cancel
                    objRegions.Undo()

                Case Else
                    Throw New Exception
            End Select
        End With

        Return objRegions
    End Function

    Public Overrides Function GetEditStyle(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.Drawing.Design.UITypeEditorEditStyle
        Return Drawing.Design.UITypeEditorEditStyle.Modal
    End Function

End Class
